<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="DBConnection.DB"%>
<%@page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>table</title>
		<link href="../../css/layer.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="../../js/jquery-ui-1.8.21.custom.min.js"></script>
	</head>
  
  <body>
    <%
    	String loctype = request.getParameter("loctype");
		String quyu = request.getParameter("quyu");
		String dwmc = request.getParameter("dwmc");
		String dwmccxfs = request.getParameter("dwmccxfs");
		String dwsx = request.getParameter("dwsx");
        String frxz = request.getParameter("frxz");
		DB db = new DB();
		db.ConnectDB();
		ResultSet rs = null;
		String sql ="select 单位名称,单位地址,单位编号  from 单位  where 1=1 ";
        if(loctype.equals("city"))
		sql += " and 所在市 = '"+quyu+"'";
		else if(loctype.equals("xian"))
		sql += " and 所在区县  = '"+quyu+"'";
		else if(loctype.equals("danwei"))
		sql += " and 单位名称  = '"+quyu+"'";
		if(!dwmc.equals(""))
			if(dwmccxfs.equals("1"))
				sql += " and 单位名称 like '"+dwmc+"'";
			else 
				sql += " and 单位名称 like '%"+dwmc+"%'";
		if(!dwsx.equals(""))
			sql += " and 单位属性   like '"+dwsx+"'";
		if(!frxz.equals(""))
			sql += " and 法人性质    like '"+frxz+"'";
		System.out.println(sql);
     %>
     	<div class="table_list">
			<table class="table1" width="100%" cellpadding="0" cellspacing="0">
				<tr class="tr_bt">
					<td class="td2">
						单位名称
					</td>
					<td class="td2">
						单位地址
					</td>
				</tr>
				<%
					rs = db.sm.executeQuery(sql);
					int i = 0;
					while (rs.next()) {
					i++;
				%>
				<tr class="tr_1">
					<td class="td2">
						<a href="dwtable2.jsp?id=<%=rs.getString(3)%>"><%=rs.getString(1)%></a>
					</td>
					<td class="td8" style="border-right: none;"><%=rs.getString(2)%></td>
				</tr>
				<%
				}
				if(i == 0){
				%>
					<tr class="tr_1">
					   <td class="td2" colspan="2">没有符合您条件的单位！</td>					
					</tr>
				<%
				}
				db.CloseDB();
				 %>
				</table>
			<table class="table1" width="100%" cellpadding="0" cellspacing="0">
				<tr class="tr_1">		
				</tr>
			</table>
				</div>
				<script>
				window.parent.$("#fanhui").hide();
				</script>
  </body>
</html>